export default {
    data () {
      return {
        tableHeight: 0,
        treeHeight: 0,
        isCollapse: true
      }
    },
    watch: {
      isCollapse () {
        this.treeHeightData()
        this.estimateTableHeight()
      }
    },
    mounted () {
      this.treeHeightData();
      this.estimateTableHeight()
      window.addEventListener('resize', () => { this.estimateTableHeight() })
      window.addEventListener('resize', () => { this.treeHeightData() })
    },
    beforeDestroy () {
      window.removeEventListener('resize', () => { this.estimateTableHeight() })
      window.removeEventListener('resize', () => { this.treeHeightData() })
    },
    methods: {
      treeHeightData(isCollapsed) {
        this.$nextTick(
          () => {
            let h = document.documentElement.clientHeight
            h=h-150
            if (this.$refs.hMain) { // 页面上如果有面包屑区域徐减去它的高度
              if (this.$refs.hMain.$el) {
                h = h - this.$refs.hMain.$el.offsetHeight
              }
            }
            this.treeHeight = h > 310 ? h : 310 // 根据自己项目定高度
            return h
          }
        )
      },
      estimateTableHeight (isCollapsed) {
        this.$nextTick(
          () => {
            let h = document.documentElement.clientHeight
            h=h-210
            if (this.$refs.queryForm) { // 页面上如果有面包屑区域徐减去它的高度
              h = h - this.$refs.queryForm.$el.offsetHeight
              // console.log(this.$refs.queryForm.$el.offsetHeight,"sdlfjkl")
            }


             if (this.$refs.refbut) { // 页面上如果有分页区域徐减去它的高度
              h = h - this.$refs.refbut.$el.offsetHeight
              // console.log(this.$refs.refbut.$el.offsetHeight,"134")
            }
            // console.log(h,"sdjfdklsjfkl")
            this.tableHeight = h > 310 ? h : 310 // 根据自己项目定高度
            return h
          }
        )
      }
    }
  }

